﻿using System;
using System.IO;
using System.Net;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Luminji.Core.Silverlight.StringTool
{
    public class StreamHelper
    {
        public MemoryStream StringToMemoryStream(string str)
        {
            using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(str)))
            {
                return stream;
            }
        }

        public string MemoryStreamToString(MemoryStream memoryStream)
        {
            try
            {
                var arr = memoryStream.ToArray();
                return Encoding.UTF8.GetString(arr, 0, arr.Length);
            }
            finally
            {
                memoryStream.Dispose();
            }
        }
    }
}
